Skip to content

refactor(changelog): better typing, yield #1453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bearomorphism
Copy link
Contributor

@bearomorphism bearomorphism commented May 24, 2025

Description

Checklist

Code Changes

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Expected Behavior

Steps to Test This Pull Request

Additional Context

Copy link

codecov bot commented May 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.62%. Comparing base (120d514) to head (9e06722).
Report is 626 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1453      +/-   ##
==========================================
+ Coverage   97.33%   97.62%   +0.28%     
==========================================
  Files          42       57      +15     
  Lines        2104     2653     +549     
==========================================
+ Hits         2048     2590     +542     
- Misses         56       63       +7     
Flag Coverage Δ
unittests 97.62% <100.00%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bearomorphism bearomorphism force-pushed the refactor-changelog-4 branch 3 times, most recently from 982859d to 42a86cc Compare May 24, 2025 08:31


def test_order_changelog_tree_raises():
change_type_order = ["BREAKING CHANGE", "feat", "refactor", "feat"]
with pytest.raises(InvalidConfigurationError) as excinfo:
changelog.order_changelog_tree(COMMITS_TREE, change_type_order)
list(changelog.order_changelog_tree(COMMITS_TREE, change_type_order))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added list here for triggering the error.

@bearomorphism bearomorphism changed the title refactor(changelog): better typing, list comprehension refactor(changelog): better typing, yield May 24, 2025
"changes": OrderedDict(
(ct, entry["changes"][ct])
for ct in change_type_order
+ sorted(set(entry["changes"].keys()) - set(change_type_order))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make these 2 logics as functions to make it more readable.

@bearomorphism bearomorphism force-pushed the refactor-changelog-4 branch from 42a86cc to b1f4853 Compare May 25, 2025 14:41
def order_changelog_tree(tree: Iterable, change_type_order: list[str]) -> Iterable:
def order_changelog_tree(
tree: Iterable[Mapping[str, Any]], change_type_order: list[str]
) -> Generator[dict[str, Any], None, None]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to make this type change, we probably would like to apply it on generate_tree_from_commits?

Copy link
Contributor Author

@bearomorphism bearomorphism May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably.

I think using Generator as the return type is more accurate because an Iterable can be iterated multiple times whereas Generator cannot. I didn't read it clearly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@bearomorphism bearomorphism mentioned this pull request May 25, 2025
10 tasks
@bearomorphism bearomorphism force-pushed the refactor-changelog-4 branch from b1f4853 to 9e06722 Compare May 25, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants